package com.crealth.memcached;

import java.util.List;
import com.crealth.db.CityDistrictDb;
import com.crealth.model.CityDistrictModel;


public class CityDistrictCached {

	private static final String Key = "all_city_district";	
	
	@SuppressWarnings("unchecked")
	public static List<CityDistrictModel> selectAllCityDistrict() {
		Object obj = MemcachedMgr.cachedClient.get(Key);
		List<CityDistrictModel> allDistrictls = null;
		if (obj == null) {
			allDistrictls = CityDistrictDb.selectAllCityDistrict();
			if (allDistrictls != null) {
				MemcachedMgr.cachedClient.set(Key, allDistrictls);
			}
		}
		else {
			allDistrictls = (List<CityDistrictModel>)obj;
		}
		
		return allDistrictls;
	}
	
	
	public static void deleteCached() {
		MemcachedMgr.cachedClient.delete(Key);
	}
	
	
}
